<template>
  <view class="richText-page">
    <u-parse :content="content"></u-parse>
  </view>
</template>
<script setup>
import { onLoad } from "@dcloudio/uni-app";
import { ref, getCurrentInstance } from "vue";
import { getClauseAgreementDetail } from "@/api";

const content = ref("");
const title = ref("");
const type = ref(1);

onLoad((option) => {
  // 两种接收参数参方式
  // 1. 直接传参
  type.value = option.type;
  if (type.value == 1) {
    title.value = "服务协议";
  } else if (type.value == 2) {
    title.value = "隐私政策条款";
  }
  // 设置标题
  uni.setNavigationBarTitle({
    title: title.value || "详情",
  });

  // 初始化
  loadList();
});

function loadList() {
  getClauseAgreementDetail({ appType: "1" }).then((res) => {
    if (res.data) {
      if (type.value == 1) {
        content.value = res.data[0].agreementText;
      } else if (type.value == 2) {
        content.value = res.data[0].clauseText;
      }
      if (!content.value) {
        content.value = "<p>暂无内容</p>";
      }
      console.log(content.value);
    }
  });
}
</script>
<style lang="scss" scoped>
page {
  background: #fff;
}
.richText-page {
  padding: 10px;
}
</style>
